import bisect
from typing import List


class Solution:
    def bestSeqAtIndex(self, height: List[int], weight: List[int]) -> int:


        Peoples = [(height[i], weight[i]) for i in range(len(height))]
        Peoples.sort(key=lambda x: (x[0], -x[1]))
        dp = []
        for pep in Peoples:
            target = bisect.bisect_left(dp, pep[1])
            if target >= len(dp):
                dp.append(pep[1])
            else:
                dp[target] = min(dp[target], pep[1])
        return len(dp)

if __name__ == '__main__':
    s = Solution()
    r = s.bestSeqAtIndex(height =[1,2,3,4], weight = [4,3,2,1])
    print(r)